<template>
  <div class="app-container dataVisualize-box">
    <div class="card top-box">
      <div class="top-content">
        <el-row v-hasRole="['admin']" type="flex" :gutter="40">
          <el-col class="mb20" :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
            <div class="item-left sle">
              <span class="left-title">总营收</span>
              <div class="img-box">
                <img src="../assets/images/home/book-sum.png" alt="" />
              </div>
              <span class="left-number">{{ pageData.totalRevenue }}</span>
            </div>
          </el-col>
          <el-col class="mb20" :xs="24" :sm="12" :md="12" :lg="18" :xl="18">
            <div class="item-center ub ub-ac ub-js ub-flow">
              <div class="gitee-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/add_person.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.rNum }}</span>
                <span class="traffic-name sle">注册用户数</span>
              </div>
              <div class="gitHub-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/add_team.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.vNum }}</span>
                <span class="traffic-name sle">会员用户数</span>
              </div>
              <div class="today-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/today.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.settlementAmounts }}</span>
                <span class="traffic-name sle">总利润</span>
              </div>
              <div class="yesterday-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/book_sum.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.orderNum }}</span>
                <span class="traffic-name sle">成交订单数</span>
              </div>
              <div class="yesterday-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/book_sum.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.refundNum }}</span>
                <span class="traffic-name sle">退款数</span>
              </div>
            </div>
          </el-col>
        </el-row>
        <el-row v-hasRole="['agent']" type="flex" :gutter="40">
          <el-col class="mb20" :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
            <div class="item-left sle">
              <span class="left-title">注册用户数</span>
              <div class="img-box">
                <img src="../assets/images/home/book-sum.png" alt="" />
              </div>
              <span class="left-number">{{ pageData.rNum }}</span>
            </div>
          </el-col>
          <el-col class="mb20" :xs="24" :sm="12" :md="12" :lg="18" :xl="18">
            <div class="item-center ub ub-ac ub-js ub-flow">
              <div class="gitee-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/add_person.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.vNum }}</span>
                <span class="traffic-name sle">会员用户数</span>
              </div>
              <div class="gitHub-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/add_team.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.settlementAmounts }}</span>
                <span class="traffic-name sle">已结算</span>
              </div>
              <div class="today-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/today.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.fSettlementAmounts }}</span>
                <span class="traffic-name sle">当月收益</span>
              </div>
              <div class="yesterday-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/book_sum.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.lSettlementAmounts }}</span>
                <span class="traffic-name sle">上月收益</span>
              </div>
              <div class="yesterday-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/book_sum.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.orderNum }}</span>
                <span class="traffic-name sle">成交订单数</span>
              </div>
              <div class="yesterday-traffic traffic-box">
                <div class="traffic-img">
                  <img src="../assets/images/home/book_sum.png" alt="" />
                </div>
                <span class="item-value">{{ pageData.refundOrderNum }}</span>
                <span class="traffic-name sle">退款数</span>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script>
import { homePage } from "@/api/system/user";
export default {
  name: "Index",
  data() {
    return {
      // 版本号
      version: "3.8.8",
      pageData: {}
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    },
    getData() {
      homePage().then(res => {
        console.log(res)
        this.pageData = res
      })
    }
  }
};
</script>

<style scoped lang="scss">
.dataVisualize-box {
  .top-box {
    box-sizing: border-box;
    padding: 25px 40px 0;
    margin-bottom: 10px;

    .top-title {
      margin-bottom: 10px;
      font-family: DIN;
      font-size: 18px;
      font-weight: bold;
    }

    .top-content {
      height: 100%;

      .item-left {
        box-sizing: border-box;
        height: 100%;
        padding: 40px 0 30px 30px;
        overflow: hidden;
        color: #ffffff;
        background: url("../assets/images/home/book-bg.png");
        background-position: 50%;
        background-size: cover;
        border-radius: 20px;

        .left-title {
          font-family: DIN;
          font-size: 20px;
        }

        .img-box {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 90px;
          height: 90px;
          margin: 40px 0 20px;
          background-color: #ffffff;
          border-radius: 20px;
          box-shadow: 0 10px 20px rgb(0 0 0 / 14%);

          img {
            width: 60px;
            height: 65px;
          }
        }

        .left-number {
          overflow: hidden;
          font-family: DIN;
          font-size: 62px;
        }
      }

      .item-center {
        // display: flex;
        // flex-wrap: wrap;
        // place-content: space-around space-between;
        height: 100%;
        column-gap: 1%;
        row-gap: 20px;

        .traffic-box {
          box-sizing: border-box;
          display: flex;
          flex-direction: column;
          width: 22%;
          height: 200px;
          padding: 25px;
          border-radius: 30px;

          .traffic-img {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 70px;
            height: 70px;
            margin-bottom: 10px;
            background-color: #ffffff;
            border-radius: 19px;
          }
        }

        img {
          width: 33px;
          height: 33px;
        }

        .item-value {
          margin-bottom: 4px;
          font-family: DIN;
          font-size: 28px;
          font-weight: bold;
          color: #1a1a37;
        }

        .traffic-name {
          overflow: hidden;
          font-family: DIN;
          font-size: 15px;
          color: #1a1a37;
          white-space: nowrap;
        }

        .gitee-traffic {
          background: url("../assets/images/home/1-bg.png");
          background-color: #e8faea;
          background-size: 100% 100%;
        }

        .gitHub-traffic {
          background: url("../assets/images/home/2-bg.png");
          background-color: #e7e1fb;
          background-size: 100% 100%;
        }

        .today-traffic {
          background: url("../assets/images/home/3-bg.png");
          background-color: #fdf3e9;
          background-size: 100% 100%;
        }

        .yesterday-traffic {
          background: url("../assets/images/home/4-bg.png");
          background-color: #f0f5fb;
          background-size: 100% 100%;
        }
      }

      .item-right {
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 430px;
        border: 1px solid var(--el-border-color);
        border-radius: 25px;

        .echarts-title {
          padding: 15px 20px;
          font-family: DIN;
          font-size: 18px;
          font-weight: bold;
          border-bottom: 1px solid var(--el-border-color);
        }

        .book-echarts {
          flex: 1;
          width: 100%;
        }
      }
    }
  }

  .bottom-box {
    position: relative;
    padding: 20px 0 0;

    .bottom-title {
      position: absolute;
      top: 75px;
      left: 50px;
      font-family: DIN;
      font-size: 18px;
      font-weight: bold;
    }

    .bottom-tabs {
      padding: 0 50px;
    }

    .curve-echarts {
      box-sizing: border-box;
      height: 400px;
      padding: 0 50px;
    }
  }
}
</style>
